#pragma once
//#include<windows.h>
#include<winsock2.h>
#include "ByteQueue.h"
#include "Connection.h"

/*
	Author: Dao Anh Vu

*/

#define MAXCLIENT 10

class Server
{
	public:
		Connection connections[MAXCLIENT];
		int numOfCon;
		HWND notifyTo;

	private:
		WSADATA wsa;
		int port;
		SOCKADDR_IN addr;
		ByteQueue *queue;
		HANDLE hThread, hQueueThread;
		DWORD dwThreadId, dwQueueThreadId;
		BOOL isRunning;
		SOCKET serverSocket;
		LONG hostname;

	public:
		Server(int p, ByteQueue *);
		~Server(void);

		void setNotifyTo(HWND hwnd);
		int broadcase(BYTE *data, int len);
		BOOL start();
		static DWORD WINAPI server_run(VOID *); 
		static DWORD WINAPI queue_handling(VOID *);
};

